home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Sources / FWOvlShp.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  8.9 KB  |  310 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWOvlShp.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWOVLSHP_H
  13. #include "FWOvlShp.h"
  14. #endif
  15.  
  16. #ifndef FWDFAULT_H
  17. #include "FWDfault.h"
  18. #endif
  19.  
  20. #ifndef FWSHAPE_H
  21. #include "FWShape.h"
  22. #endif
  23.  
  24. #ifndef FWGC_H
  25. #include "FWGC.h"
  26. #endif
  27.  
  28. #ifndef FWRECSHP_H
  29. #include "FWRecShp.h"
  30. #endif
  31.  
  32. #ifndef FWRRCSHP_H
  33. #include "FWRRcShp.h"
  34. #endif
  35.  
  36. #ifndef FWARCSHP_H
  37. #include "FWArcShp.h"
  38. #endif
  39.  
  40. #ifndef FWLINSHP_H
  41. #include "FWLinShp.h"
  42. #endif
  43.  
  44. #ifndef FWRGNSHP_H
  45. #include "FWRgnShp.h"
  46. #endif
  47.  
  48. #ifndef FWGRUTIL_H
  49. #include "FWGrUtil.h"
  50. #endif
  51.  
  52. // ----- OpenDoc Includes -----
  53.  
  54. #ifndef _TRNSFORM_
  55. #include <Trnsform.h>
  56. #endif
  57.  
  58. //==============================================================================
  59. //    •• RunTime Info
  60. //==============================================================================
  61.  
  62. #ifdef FW_BUILD_MAC
  63. #pragma segment fwgraphx
  64. #endif
  65.  
  66. //==============================================================================
  67. //    •• class FW_COvalShape
  68. //==============================================================================
  69.  
  70. //------------------------------------------------------------------------------
  71. // FW_COvalShape::FW_COvalShape
  72. //------------------------------------------------------------------------------
  73.  
  74. FW_COvalShape::FW_COvalShape() :
  75.     FW_CShape()
  76. {
  77. }
  78.  
  79. //------------------------------------------------------------------------------
  80. // FW_COvalShape::FW_COvalShape
  81. //------------------------------------------------------------------------------
  82.  
  83. FW_COvalShape::FW_COvalShape(const FW_CRect& rect) :
  84.     FW_CShape()
  85. {
  86.     SetRep(new FW_COvalShapeRep(rect));
  87. }
  88.  
  89. //------------------------------------------------------------------------------
  90. // FW_COvalShape::FW_COvalShape
  91. //------------------------------------------------------------------------------
  92.  
  93. FW_COvalShape::FW_COvalShape(const FW_COvalShape& other) :
  94.     FW_CShape(other)
  95. {
  96. }
  97.  
  98. //------------------------------------------------------------------------------
  99. // FW_COvalShape::FW_COvalShape
  100. //------------------------------------------------------------------------------
  101.  
  102. FW_COvalShape::FW_COvalShape(FW_COvalShapeRep* rep) :
  103.     FW_CShape(rep)
  104. {
  105. }
  106.  
  107. //------------------------------------------------------------------------------
  108. // FW_COvalShape::operator=
  109. //------------------------------------------------------------------------------
  110.  
  111. FW_COvalShape& FW_COvalShape::operator=(const FW_COvalShape& other)
  112. {
  113.     SetRep(other.GetRep());
  114.     return *this;
  115. }
  116.  
  117. //------------------------------------------------------------------------------
  118. // FW_COvalShape::operator=
  119. //------------------------------------------------------------------------------
  120.  
  121. FW_COvalShape& FW_COvalShape::operator=(FW_COvalShapeRep* other)
  122. {
  123.     SetRep(other);
  124.     return *this;
  125. }
  126.  
  127. //------------------------------------------------------------------------------
  128. // FW_COvalShape::operator FW_CRectShape
  129. //------------------------------------------------------------------------------
  130.  
  131. FW_COvalShape::operator FW_CRectShape() const
  132. {    
  133.     FW_CRectShape rectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  134.     rectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  135.     return rectShape;
  136. }
  137.  
  138. //------------------------------------------------------------------------------
  139. // FW_COvalShape::operator FW_CRoundRectShape
  140. //------------------------------------------------------------------------------
  141.  
  142. FW_COvalShape::operator FW_CRoundRectShape() const
  143. {    
  144.     FW_CRoundRectShape roundRectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), FW_kZeroPoint);
  145.     roundRectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  146.     return roundRectShape;
  147. }
  148.  
  149. //------------------------------------------------------------------------------
  150. // FW_COvalShape::operator FW_CArcShape
  151. //------------------------------------------------------------------------------
  152.  
  153. FW_COvalShape::operator FW_CArcShape() const
  154. {    
  155.     FW_CArcShape arcShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), 0, 0);
  156.     arcShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  157.     return arcShape;
  158. }
  159.  
  160. //------------------------------------------------------------------------------
  161. // FW_COvalShape::operator FW_CLineShape
  162. //------------------------------------------------------------------------------
  163.  
  164. FW_COvalShape::operator FW_CLineShape() const
  165. {    
  166.     FW_CRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
  167.     FW_CLineShape lineShape(rect[FW_kTopLeft], rect[FW_kBotRight]);
  168.     lineShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  169.     return lineShape;
  170. }
  171.  
  172. //------------------------------------------------------------------------------
  173. // FW_COvalShape::operator FW_CRegionShape
  174. //------------------------------------------------------------------------------
  175.  
  176. FW_COvalShape::operator FW_CRegionShape() const
  177. {    
  178.     XMPShape *xmpShape = NULL;
  179.     
  180. #ifdef FW_BUILD_MAC
  181.     GrafPtr svPort;
  182.     ::GetPort(&svPort);
  183.     ::SetPort(gGraphicGlobales.gScratchWindow);
  184.     ::OpenRgn();
  185.     FW_SPlatformRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
  186.     ::FrameOval(&rect);
  187.     FW_PlatformRegion rgn = ::NewRgn();
  188.     ::CloseRgn(rgn);
  189.     xmpShape = ::NewXMPShape(rgn);
  190.     ::SetPort(svPort);
  191. #endif
  192.  
  193. #ifdef FW_BUILD_WIN
  194.     NotYetImplemented();
  195. #endif
  196.  
  197.     FW_CRegionShape regionShape(xmpShape);
  198.     regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  199.     return regionShape;
  200. }
  201.  
  202. //==============================================================================
  203. //    •• class FW_COvalShapeRep
  204. //==============================================================================
  205.  
  206. //------------------------------------------------------------------------------
  207. //    • FW_COvalShapeRep::FW_COvalShapeRep
  208. //------------------------------------------------------------------------------
  209.  
  210. FW_COvalShapeRep::FW_COvalShapeRep() :
  211.     FW_CBoundedShapeRep(gGraphicGlobales.gOval, FW_CRect(0,0,0,0))
  212. {
  213. }
  214.  
  215. //------------------------------------------------------------------------------
  216. //    • FW_COvalShapeRep::FW_COvalShapeRep
  217. //------------------------------------------------------------------------------
  218.  
  219. FW_COvalShapeRep::FW_COvalShapeRep(const FW_CRect& rect) :
  220.     FW_CBoundedShapeRep(gGraphicGlobales.gOval, rect)
  221. {
  222. }
  223.  
  224. //------------------------------------------------------------------------------
  225. //    • FW_COvalShapeRep::~FW_COvalShapeRep
  226. //------------------------------------------------------------------------------
  227.  
  228. FW_COvalShapeRep::~FW_COvalShapeRep()
  229. {
  230. }
  231.  
  232. //------------------------------------------------------------------------------
  233. //    • FW_COvalShapeRep::Draw
  234. //------------------------------------------------------------------------------
  235.  
  236. void FW_COvalShapeRep::Draw(FW_CGraphicContext* graphicContext)
  237. {    
  238.     FW_ShapeFills shapeFill = GetShapeFill();
  239.  
  240.     if (shapeFill == FW_kNullShape)
  241.         return;
  242.         
  243.     graphicContext->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kGeometricShape, shapeFill);
  244.     
  245.     FW_SPlatformRect rect = graphicContext->AsPlatformRect(fRect);
  246.  
  247. #ifdef FW_BUILD_MAC
  248.     if (shapeFill == FW_kFramed)
  249.         ::FrameOval(&rect);
  250.     else
  251.         ::PaintOval(&rect);
  252. #endif
  253. #ifdef FW_BUILD_WIN
  254.         ::Ellipse(graphicContext->GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  255. #endif
  256. }
  257.  
  258. //------------------------------------------------------------------------------
  259. //    • FW_COvalShapeRep::DrawOval
  260. //------------------------------------------------------------------------------
  261.  
  262. void FW_COvalShapeRep::DrawOval(FW_CGraphicContext* graphicContext, const FW_CRect& rect)
  263. {    
  264.     if (gGraphicGlobales.gOval.fFill == FW_kNullShape)
  265.         return;
  266.  
  267.     graphicContext->SelectInkAndStyle(gGraphicGlobales.gOval.fInk, gGraphicGlobales.gOval.fStyle, FW_kGeometricShape, gGraphicGlobales.gOval.fFill);
  268.  
  269.     FW_SPlatformRect qdRect = graphicContext->AsPlatformRect(rect);
  270.  
  271. #ifdef FW_BUILD_MAC
  272.     if (gGraphicGlobales.gOval.fFill == FW_kFramed)
  273.         ::FrameOval(&qdRect);
  274.     else
  275.         ::PaintOval(&qdRect);
  276. #endif
  277. #ifdef FW_BUILD_WIN
  278.         ::Ellipse(graphicContext->GetHDC(), qdRect.left, qdRect.top, qdRect.right, qdRect.bottom);
  279. #endif
  280. }
  281.  
  282. //------------------------------------------------------------------------------
  283. //    • FW_COvalShapeRep::SetAsDefault
  284. //------------------------------------------------------------------------------
  285.  
  286. void FW_COvalShapeRep::SetAsDefault() const
  287. {
  288.     SetDefaultProperties(gGraphicGlobales.gOval);
  289. }
  290.  
  291. //------------------------------------------------------------------------------
  292. //    • FW_COvalShapeRep::HitTest
  293. //------------------------------------------------------------------------------
  294.  
  295. FW_HitTestPart FW_COvalShapeRep::HitTest(const FW_CPoint& test) const
  296. {
  297.     return FW_kOutside;
  298. }
  299.  
  300. //----------------------------------------------------------------------------------------
  301. //    • FW_COvalShapeRep::Copy
  302. //----------------------------------------------------------------------------------------
  303.  
  304. FW_COvalShape FW_COvalShapeRep::Copy() const
  305. {
  306.     FW_COvalShape oval(fRect);
  307.     return oval;
  308. }
  309.  
  310.